
//这个题挺有意思，我做了好久，考虑用坐标范围代表地毯
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#include <stdio.h>

#define N 10000

int main()
{
    long carpet[N][4] = { {0} }, x, y;
    int on_carpet = -1, n;
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%ld%ld%ld%ld", &carpet[i][0], &carpet[i][1], &carpet[i][2], &carpet[i][3]);
    }
    scanf("%ld%ld", &x, &y);
    for (i = 0; i < n; i++) {
        if (carpet[i][0] <= x && x <= carpet[i][0] + carpet[i][2] && carpet[i][1] <= y && y <= carpet[i][1] + carpet[i][3])
        {
            on_carpet = i + 1;
        }
    }
    printf("%d", on_carpet);
    return 0;
}
